package com.xneure.code.plantask;

public class CountTask extends PlanTask{
	private long runCount = -1;

	public CountTask(){
		this(-1);
	}
	public CountTask(int runCount){
		this.runCount = runCount;
	}
	@Override
	public boolean checkParam(){
		if(runCount != 0){
			currRunCount = 0;
			return true;
		}else{
			return false;
		}
	}

	protected boolean isStop(){
		return (runCount == -1 ? false : currRunCount > runCount);
	}

	@Override
	public void end(){
		currRunCount = 0;
		super.end();
	}

	/**
	 * 获取要执行的次数
	 * 
	 * @return long
	 */
	public long getCurrRunCount(){
		return currRunCount;
	}

	/**
	 * 设置要执行的次数 可以不指定开始和结束时间
	 * 
	 * @param runCount void
	 */
	public void setRunCount(long runCount){
		this.runCount = runCount;
	}
}
